﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TimbreRecognition.Recognition.Model
{
    public class NeuronNetwork : INetwork
    {

        private List<NeuronLayer> layers = new List<NeuronLayer>();

        public double[] getOutput()
        {
            int size = layers.Count;
            NeuronLayer layer = layers[size - 1];
            return layer.getOutput();
        }

        public void recalculateOutput(double[] input)
        {
            for (int i = 0; i < layers.Count; i++)
            {
                NeuronLayer layer = layers[i];
                double[] layerInput;
                if (i == 0)
                {
                    layerInput = input;
                }
                else
                {
                    NeuronLayer previousLayer = layers[i - 1];
                    layerInput = previousLayer.getOutput();
                }
                layer.recalculateOutput(layerInput);
            }
        }

        public void addLayer(NeuronLayer layer)
        {
            layers.Add(layer);
        }

        public List<NeuronLayer> getLayers()
        {
            return layers;
        }

        public void setLayers(List<NeuronLayer> layers)
        {
            this.layers = layers;
        }
    }
}
